/*
 * Copyright (C) 2023 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
 * use this file except in compliance with the License. You may obtain a copy of
 * the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations under
 * the License.
 */
package com.google.cloud.teleport.it.datadog;

import java.util.HashMap;
import java.util.Map;
import java.util.UUID;

/** Utilities for {@link DatadogResourceManager} implementations. */
public final class DatadogResourceManagerUtils {

  // Datadog event metadata keys
  private static final String DD_SOURCE_KEY = "ddsource";
  private static final String DD_TAGS_KEY = "ddtags";
  private static final String DD_HOSTNAME_KEY = "hostname";
  private static final String DD_SERVICE_KEY = "service";
  private static final String DD_MESSAGE_KEY = "message";

  private DatadogResourceManagerUtils() {}

  public static Map<String, Object> datadogEntryToMap(DatadogLogEntry entry) {
    Map<String, Object> eventMap = new HashMap<>();
    eventMap.put(DD_SOURCE_KEY, entry.ddsource());
    eventMap.put(DD_TAGS_KEY, entry.ddtags());
    eventMap.put(DD_HOSTNAME_KEY, entry.hostname());
    eventMap.put(DD_SERVICE_KEY, entry.service());
    eventMap.put(DD_MESSAGE_KEY, entry.message());

    return eventMap;
  }

  /**
   * Generates a secure, valid Datadog API key.
   *
   * @return The generated password.
   */
  static String generateApiKey() {
    return UUID.randomUUID().toString();
  }
}
